<?php
if (!defined('ZAZA')) exit('No direct script access allowed');
/**
 * @copyright     ZaZa Group
 * @author        Sir Doan
 */
class AdminGameAdd extends Form
{
    function __construct()
    {                          
        Form::__construct('AdminGameAddForm'); 
        tpl()->layout = 'admin';  
    }  
    // Method Submit
    function is_submit()
    {
         $gameInfo = array( 'gamename' => Obj()->get('title'), 
                            'description' => Obj()->get('description'), 
                            'parentid' => Obj()->get('parentid', 'int', 0));
         require_once MODEL_PATH . DS .'AdminGame_model.php';
         $objGame = new AdminGame_Model();
         $res = $objGame->add($gameInfo);
         if($res)
            Url::redirectUrl(Url::buildUrl(null, 'admin_game', true), true);
    }
    // Method Draw
    function draw()
    {              
        $sites = db()->select('site', 'siteid, title', 'status = 1');
        tpl()->assign('sites', $sites);
        $games = db()->select('game', '*', 'parentid = 0 AND status = 1');
        tpl()->assign('games', $games);
        tpl()->assign('form', array('begin' => $this->begin(), 'end' => $this->end()));
        return tpl()->display('admin_game_add'); 
    }
}  
?>
